/*
 * 前端客户基础类
 * @author: huangzong
 */
import headimg from '#/static/img/headimg.jpg'
import C from '#/src/common/common.js'

class Guest {
    constructor() {}

    /*
     * 打开顾客页面函数
     */
    async openGuestPage(id) {
        return await C.openBrowserWindow('/', { id: id }, {
            transparent: true,
            frame: false,
            // openDevTools: true,
            width: 1100,
            height: 700,
            useSpa: true,
            spaModel: 'guest'
        })
    }

    /*
     * 打开新增客户
     */
    async openAddGuest(row) {
        return await C.openBrowserWindow('/addGuest', row, {
            transparent: true,
            frame: false,
            // openDevTools: true,
            width: 420,
            height: 435,
            useSpa: true,
            spaModel: 'shop'
        })
    }


    /*
     * 请求客户的详细信息
     */
    async getGuestInfo(id) {
        let data = await C.ajax('/shop/guest/guest', { gid: id })
        if (data) data.headurl = data.headurl != 0 ? data.headurl : headimg
        return data
    }

    /*
     * 获取客户的账户信息
     */
    async getGuestAccountInfo (id) {
        return await C.ajax('/shop/guest/queryginfo', { id: id }, 'post')
    }

    /*
     * 获取客户的服务人员
     */
    async getGuestServiceMan(id) {
        return await C.ajax('/shop/guest/getGuestServiceMan', { id: id })
    }

    /*
     * 获取客户的列表信息
     */
    async getGuestList(filter) {
        return await C.ajax('/shop/popup/getguestlist', filter)
    }

    /*
     * 查询跨店消费客户信息（只授予部分查询信息）
     */
    async getDepartmentGuestList(filter) {
        return await C.ajax('/shop/popup/getDepartmentGuestList', filter)
    }

    /*
     * 新增客户
     */

    async addGuest(data) {
        return await C.ajax('/shop/guest/addguest', data, 'post')
    }
}

export default new Guest()